shouldBeSameJsonAs

If two strings represent the same JSON regardless of formatting

void
shouldBeSameJsonAs
@trusted
(
in string actual
,
in string expected
,
in string file = __FILE__
,
in size_t line = __LINE__
)

Examples

1 // not pure because parseJSON isn't pure
2    `{"foo": "bar"}`.shouldBeSameJsonAs(`{"foo": "bar"}`);
3    `{"foo":    "bar"}`.shouldBeSameJsonAs(`{"foo":"bar"}`);
4    `{"foo":"bar"}`.shouldBeSameJsonAs(`{"foo": "baz"}`).shouldThrow!UnitTestException;
5    try
6        `oops`.shouldBeSameJsonAs(`oops`);
7    catch (Exception e)
8        assert(e.msg == "Error parsing JSON: Unexpected character 'o'. (Line 1:1)");

Meta